﻿var jsonpcallback = {
    LoginCallback: function (data) {
        $.login.submitOrderFlow.completed();
        if (data) {
            if (typeof ($.login.callback) === "function") {
                $.login.callback(data);
                llb_global.utils.setCookie("phone", ""); //提交订单还是要清空的
               
            }
        }
    },
    Find310CouponCallback: function (data) {
        if (data && data.state == "success") {
            $("#coupon310").attr("src", llb_global.config.api + "couponimg/310/" + data.data + ".png").css({ opacity: 0 });
            $("#p_couponcode").html("券号：" + data.data);
        } else {
            alert("此用户暂无抵用券");
            window.location.href = "index.html";
        }
    },
    FindAllCouponCallback: function (data) {
        var html = "";
        if (data && data.state == "success") {
            if (data.data.length > 0) {
                var tpl = '<div class="proportionate p4142 voucher {usedclass}">';
                tpl += ' <div class="p-content">';
                tpl += '<table>';
                tpl += ' <tr>';
                tpl += ' <td class="v-title" rowspan="3">抵<br />用<br />券</td>';
                tpl += ' <td class="title">{couponname}</td>';
                tpl += '</tr>';
                tpl += '<tr>';
                tpl += ' <td class="price">{couponvalue}<span>元</span></td>';
                tpl += '</tr>';
                tpl += '<tr>';
                tpl += ' <td class="no">券号：{couponcode}</td>';
                tpl += '</tr>';
                tpl += ' </table>';
                tpl += '</div>';
                tpl += '</div>';
                for (var i = 0; i < data.data.length; i++) {
                    html += tpl.replace("{usedclass}", data.data[i].IsUsed ? "used" : "")
                        .replace("{couponname}", data.data[i].CouponValue == 310 ? "宝骏310W购车现金抵用券" : "五菱宝骏汽车售后现金抵用券")
                        .replace("{couponvalue}", data.data[i].CouponValue)
                        .replace("{couponcode}", data.data[i].CouponCode);
                }
                $("body").html(html);
            }
        }
        if (html.length == 0) {
            alert("此用户暂无抵用券");
            window.location.href = "index.html";
        }
    },
    Find200CouponCallback: function (data) {
        if (data && data.state == "success") {
            $("#coupon200").attr("src", llb_global.config.api + "couponimg/200/" + data.data + ".png").css({ opacity: 0 });
            $("#p_couponcode").html("券号：" + data.data);
        } else {
            alert("此用户暂无工时券");
            window.location.href = "index.html";
        }
    },
    GetDealerCallback: function (data) {
        var o = data;
        var list = o.data;
        var infos = [];
        var info;
        var tpl = "<option value=\"{did}\">{dname}</option>";
        infos.push("<option value=\"0\">请选择</option>");
        for (var i = 0; i < list.length; i++) {
            info = list[i];
            infos.push(tpl.replace("{did}", info.DealerID).replace("{dname}", info.DealerName));
        }
        $("#J_dealer").html(infos.join(""));
    },
    SubmitOrderCallback: function (data) {
        $.dcorder.submitOrderFlow.completed();
        if (data) {
            if (typeof ($.dcorder.callback) === "function") {
                llb_global.utils.setCookie("dcorder", ""); //提交订单还是要清空的
                $.dcorder.callback(data);
            }
        }
    }
};